package jdbc;

import javax.print.DocFlavor;
import java.sql.*;

public class Demo6 {
    public static void main(String[] args) throws SQLException {
        try {
            Connection con=DBUtil.getConnection();
            Statement statement=con.createStatement();
            String sql="SELECT c.name,c.floor,t.name,t.salary,t.title"+
                       " FROM class c"+
                       " JOIN teacher t ON c.teacher_id=t.id";
            ResultSet res=statement.executeQuery(sql);
            while(res.next()){
                String cName=res.getString("c.name");
                int cFloor=res.getInt("c.floor");
                String tName=res.getString("t.name");
                int tSalary=res.getInt("t.salary");
                String tTitle=res.getString("t.title");
                System.out.println(cName+" "+cFloor+" "+tName+" "+tSalary+" "+tTitle);


            }
        } catch (SQLException e) {
            e.printStackTrace();
        }

    }
}
